package com.eudon.design_pattern.creational.factory;

import com.eudon.design_pattern.creational.factory.factory.Factory;
import com.eudon.design_pattern.creational.factory.factory.KeyboardFactory;
import com.eudon.design_pattern.creational.factory.factory.MouseFactory;
import com.eudon.design_pattern.creational.factory.product.Product;

/**
 * @author eudon
 * @description 使用案例
 * @date 2025/9/1
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class Use {
    public static void main(String[] args) {
        getProduct(new MouseFactory());
        getProduct(new KeyboardFactory());
    }

    /**
     * 接口提供方，调用方无需关注内部怎么实现的，只需要传入产品对应的工厂实例即可
     *
     * @param factory 工厂实例
     */
    private static void getProduct(Factory factory) {
        Product product = factory.createProduct();
        System.out.println(product.getName());
    }
}
